package leetcode3;

public class Day2 {



    //搜索二维矩阵
    public boolean searchMatrix(int[][] matrix, int target) {
        int n = matrix.length,m = matrix[0].length;
        int i=0,j=m-1;
        while(i>=0&&i<n && j>=0&& j<m) {
            if(matrix[i][j] > target) j--;
            else if(matrix[i][j] < target) i++;
            else return true;
        }
        return false;
    }

    public boolean CheckPermutation(String s1, String s2) {
        int[] map1 = new int[26];
        int[] map2 = new int[26];
        for(int i=0;i<s1.length();i++) {
            map1[(int)s1.charAt(i)-97]++;
        }
        for(int i=0;i<s2.length();i++) {
            map2[(int)s2.charAt(i)-97]++;
        }
        for(int i=0;i<26;i++) {
            if(map1[i]!=map2[i]) return false;
        }
        return true;
    }
}
